<?php 
// error_reporting(0);
    header("content-type:text/html;charset=utf-8");
    //接收数据
    // $name = $_GET['name'];
    // $phone = $_GET['phone'];
    // $study = $_GET['study'];
    // $age = $_GET['age'];
    // $money = $_GET['money'];

    //链接

    $db = mysqli_connect("localhost", "root", "", "zggys");

    if (!$db) {
             die('连接错误: ' . mysqli_error($db));
        }
        echo '连接成功<br />';

    //执行
    // $sqlStr = "insert into people(username,pwd,name,phone,,)
    // value('".$username."','".$pwd."','".$name."','".$phone."')";

    // $result = mysql_query($sqlStr,$conn);

    $username = $_REQUEST['username'];
    $name = $_REQUEST['name'];
    $phone = $_REQUEST['phone'];
    $pwd = $_REQUEST['password'];
    // var_dump($_REQUEST);
    // var_dump($username);
    // var_dump($name);
    // var_dump($phone);
    // var_dump($pwd);
    //  print_r($_REQUEST);

      
      // $username = "a123";
      // $name = "asd2655";
      // $phone = "13543385370";
      // $pwd = "asdf";



    // $sql = "SELECT * FROM `user` WHERE username = '$username'";

    // $r = mysqli_query($db, $sql);
    
    // $num= mysqli_num_rows($r); /* 该方法得到的是记录的条数:$r["num_rows"]  */
    // echo $num;
    /* + 检查：检查当前的用户名在数据库中是否已经存在，如果存在那么就应该提示，否则就插入 */ 
    // if($num == 1){
      // echo '{"status":"error","msg":"该用户已经存在，请重新填写注册的昵称!!"}';
      
    // }else{
      $sql = "INSERT INTO user " .
        "(id,username,password,name,phone)" .
        "VALUES " .
        "(NULL,'$username','$pwd','$name',$phone)";
    // }
    
      // $retval = mysqli_query($db, $sql);
      mysqli_query($db, $sql);
    
      // if (!$retval) {
        // die('无法插入数据: ' . mysqli_error($db));
      // }else{
        $success =array("status"=>"success");
        $s = json_encode($success,true);
      echo $s;
      // }
// echo"1";

    //断开

    // mysqli_close($db);

 

?>